package routes

import (
	"gin-study/app/http/controllers/v1"
	"gin-study/app/http/middlewares"
	"gin-study/pkg/helper"
	"github.com/gin-gonic/gin"
)

func RegisterV1Routes(router *gin.Engine) {
	routerV1 := router.Group("/v1")

	auth := routerV1.Group("/auth")
	{
		auth.POST("/register", helper.WarpHandle(v1.Auth.Register))
		auth.POST("/login", helper.WarpHandle(v1.Auth.Login))
	}

	//鉴权路由
	routerV1.Use(middlewares.Auth())
	{
		restRoute(routerV1, "/orders", v1.Order)

		user := routerV1.Group("/users")
		{
			restRoute(user, "/", v1.User)
		}

		userCenter := routerV1.Group("/userCenter")
		{
			restRoute(userCenter, "/", v1.UserCenter)
		}

		userOrders := routerV1.Group("/users/:id/orders")
		{
			userOrders.GET("/", helper.WarpHandle(v1.UserOrder.Index))
		}

	}
}
